#!/bin/bash
ip=`ifconfig eth1|sed -n '2p'|sed 's/.*addr:\(.*\) Bcast.*/\1/g'`
ip1=`echo $ip|cut -d. -f4`
#修改主机名
sed -i "/HOSTNAME=/c HOSTNAME=server$ip1.itcast.cc" /etc/sysconfig/network
echo "$ip       server$ip1.itcast.cc" >> /etc/hosts
#配置yum源
mount /dev/sr0 /mnt/ &> /dev/null
cat > /etc/yum.repos.d/local.repo <<-EOF
[local]
name=local yum
baseurl=file:///mnt
enabled=1
gpgcheck=0
EOF
#关闭防火墙和selinux
service iptables stop &>/dev/null
setenforce 0 &>/dev/null
#sed -i '/SELINUX=/c SELINUX=disabled' /etc/selinux/config